package net.sxnic.workflow.whimpl;

import net.sxnic.ugr.UgrConstant;
import net.sxnic.workflow.context.WfContextImpl;
import net.sxnic.workflow.handler.AbstractHandler;
import net.sxnic.workflow.handler.HandlerExt;
import net.sxnic.workflow.handler.WfHandlerException;
import net.sxnic.workflow.task.Task;
import net.sxnic.workflow.wfentity.WfEntity;

/**
 * 退回处理
 * @author 孙宇飞
 *
 */
public class SendBackHandler extends AbstractHandler<WfEntity> implements
		HandlerExt<WfEntity> {

	public SendBackHandler(WfContextImpl<WfEntity> context) {
		super(context);
	}

	@Override
	public void editExecute() throws WfHandlerException {
		
		if(context.getTask().isReturnBack()){			
			context.setErrorMsg("此文件由\""
					+ UgrConstant.USER_MAP.get(context.getTask().getReturnBackFromMan())
					+ "\"退回！退回意见：\"" + context.getTask().getFromTask().getComments() + "\"");
		}
	}

	@Override
	public void saveExecute() throws WfHandlerException {

	}

	@Override
	public void viewExecute() throws WfHandlerException {

	}

	@Override
	public void submitExecute() throws WfHandlerException {
		//直接退回到拟稿人
		context.getTaskManager().returnBack(context.getTask().getId(), context.getTask().getContinueType(),
				context.getTaskComment());
		
	}

}
